<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: ActiveRecord::Base</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">ActiveRecord::Base</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/vendor/plugins/active_scaffold/lib/extensions/to_label_rb.html">
                vendor/plugins/active_scaffold/lib/extensions/to_label.rb
                </a>
        <br />
                <a href="../../files/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated_rb.html">
                vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb
                </a>
        <br />
                <a href="../../files/vendor/plugins/active_scaffold/lib/extensions/unsaved_record_rb.html">
                vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
a simple (manual) <a href="Base.html#M000064">unsaved?</a> flag and method.
at least it automatically reverts after a save!
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000058">associated_valid?</a>&nbsp;&nbsp;
      <a href="#M000062">associations_for_update</a>&nbsp;&nbsp;
      <a href="#M000061">no_errors_in_associated?</a>&nbsp;&nbsp;
      <a href="#M000059">save_associated</a>&nbsp;&nbsp;
      <a href="#M000060">save_associated!</a>&nbsp;&nbsp;
      <a href="#M000065">save_with_unsaved_flag</a>&nbsp;&nbsp;
      <a href="#M000057">to_label</a>&nbsp;&nbsp;
      <a href="#M000063">unsaved=</a>&nbsp;&nbsp;
      <a href="#M000064">unsaved?</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000058" class="method-detail">
        <a name="M000058"></a>

        <div class="method-heading">
          <a href="#M000058" class="method-signature">
          <span class="method-name">associated_valid?</span><span class="method-args">(path = [])</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000058-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb, line 3</span>
3:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">associated_valid?</span>(<span class="ruby-identifier">path</span> = [])
4:     <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>) <span class="ruby-comment cmt"># prevent recursion (if associated and parent are new records)</span>
5:     <span class="ruby-identifier">path</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword kw">self</span>
6:     <span class="ruby-comment cmt"># using [].all? syntax to avoid a short-circuit</span>
7:     <span class="ruby-identifier">with_unsaved_associated</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">a</span>.<span class="ruby-identifier">valid?</span>, <span class="ruby-identifier">a</span>.<span class="ruby-identifier">associated_valid?</span>(<span class="ruby-identifier">path</span>)].<span class="ruby-identifier">all?</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>} }
8:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000061" class="method-detail">
        <a name="M000061"></a>

        <div class="method-heading">
          <a href="#M000061" class="method-signature">
          <span class="method-name">no_errors_in_associated?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000061-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb, line 18</span>
18:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">no_errors_in_associated?</span>
19:     <span class="ruby-identifier">with_unsaved_associated</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">errors</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">no_errors_in_associated?</span>}
20:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000059" class="method-detail">
        <a name="M000059"></a>

        <div class="method-heading">
          <a href="#M000059" class="method-signature">
          <span class="method-name">save_associated</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000059-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb, line 10</span>
10:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_associated</span>
11:     <span class="ruby-identifier">with_unsaved_associated</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">a</span><span class="ruby-operator">|</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">save</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">a</span>.<span class="ruby-identifier">save_associated</span> }
12:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000060" class="method-detail">
        <a name="M000060"></a>

        <div class="method-heading">
          <a href="#M000060" class="method-signature">
          <span class="method-name">save_associated!</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000060-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb, line 14</span>
14:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_associated!</span>
15:     <span class="ruby-identifier">save_associated</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">raise</span>(<span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">RecordNotSaved</span>)
16:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000065" class="method-detail">
        <a name="M000065"></a>

        <div class="method-heading">
          <a href="#M000065" class="method-signature">
          <span class="method-name">save_with_unsaved_flag</span><span class="method-args">(*args)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
automatically unsets the unsaved flag
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000065-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb, line 14</span>
14:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_with_unsaved_flag</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
15:     <span class="ruby-identifier">result</span> = <span class="ruby-identifier">save_without_unsaved_flag</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
16:     <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">unsaved</span> = <span class="ruby-keyword kw">false</span>
17:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
18:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000057" class="method-detail">
        <a name="M000057"></a>

        <div class="method-heading">
          <a href="#M000057" class="method-signature">
          <span class="method-name">to_label</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000057-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/to_label.rb, line 3</span>
3:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_label</span>
4:     [<span class="ruby-identifier">:name</span>, <span class="ruby-identifier">:label</span>, <span class="ruby-identifier">:title</span>, <span class="ruby-identifier">:to_s</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attribute</span><span class="ruby-operator">|</span>
5:       <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">attribute</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">attribute</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">attribute</span>).<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">String</span>)
6:     <span class="ruby-keyword kw">end</span>
7:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000063" class="method-detail">
        <a name="M000063"></a>

        <div class="method-heading">
          <a href="#M000063" class="method-signature">
          <span class="method-name">unsaved=</span><span class="method-args">(val)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
acts like a dirty? flag, manually thrown during update_record_from_params.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000063-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb, line 4</span>
4:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unsaved=</span>(<span class="ruby-identifier">val</span>)
5:     <span class="ruby-ivar">@unsaved</span> = (<span class="ruby-identifier">val</span>) <span class="ruby-operator">?</span> <span class="ruby-keyword kw">true</span> <span class="ruby-operator">:</span> <span class="ruby-keyword kw">false</span>
6:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000064" class="method-detail">
        <a name="M000064"></a>

        <div class="method-heading">
          <a href="#M000064" class="method-signature">
          <span class="method-name">unsaved?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
whether the <a href="Base.html#M000064">unsaved?</a> flag has been thrown
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000064-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb, line 9</span>
 9:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unsaved?</span>
10:     <span class="ruby-ivar">@unsaved</span>
11:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000062" class="method-detail">
        <a name="M000062"></a>

        <div class="method-heading">
          <a href="#M000062" class="method-signature">
          <span class="method-name">associations_for_update</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Provide an override to allow the model to restrict which associations are
considered by ActiveScaffolds update mechanism. This allows the model to
restrict things like Acts-As-Versioned versions associations being
traversed.
</p>
<p>
By defining the method :scaffold_update_nofollow returning an array of
associations these associations will not be traversed. By defining the
method :scaffold_update_follow returning an array of associations, only
those associations will be traversed.
</p>
<p>
Otherwise the default behaviour of traversing all associations will be
preserved.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000062-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb, line 34</span>
34:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">associations_for_update</span>
35:     <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>( <span class="ruby-identifier">:scaffold_update_nofollow</span> )
36:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">reflect_on_all_associations</span>.<span class="ruby-identifier">reject</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">association</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scaffold_update_nofollow</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">association</span>.<span class="ruby-identifier">name</span> ) }
37:     <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">respond_to?</span>( <span class="ruby-identifier">:scaffold_update_follow</span> )
38:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">reflect_on_all_associations</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">association</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">scaffold_update_follow</span>.<span class="ruby-identifier">include?</span>( <span class="ruby-identifier">association</span>.<span class="ruby-identifier">name</span> ) }
39:     <span class="ruby-keyword kw">else</span>
40:       <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">reflect_on_all_associations</span>
41:     <span class="ruby-keyword kw">end</span>
42:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>